package com.zanbo.clock.controller;

import com.zanbo.clock.domain.entity.Staff;
import com.zanbo.clock.exception.ServiceException;
import com.zanbo.clock.model.base.bean.ResponseBean;
import com.zanbo.clock.model.base.out.ClockInfo;
import com.zanbo.clock.model.code.ErrorCode;
import com.zanbo.clock.service.ClockService;
import com.zanbo.clock.service.StaffService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zanbo
 * @description: 签到控制类
 * @date: 上午 11:00 2021-4-26
 */
@RestController
public class ClockController {
    
    @Autowired
    private ClockService clockService;
    
    /**
     * @author: zanbo
     * @description: 签到方法，传入参数为员工编号，会根据相应时间判断签到事件并完成员工的签到
     * @date: 上午 11:00 2021-4-26
     * @params [id]
     * @return com.zanbo.clock.model.base.bean.ResponseBean
     */
    @PostMapping("clock")
    public ResponseBean Clock(@Param("id") String id) {
        if (id == null) {
            throw new ServiceException(ErrorCode.NONULL);
        }
        ClockInfo clockInfo = clockService.doClock(Long.parseLong(id));
        return ResponseBean.success(clockInfo);
    }
    
}
